package mercurius.fitness.client.rb.diet.forms;

import com.google.gwt.user.client.rpc.AsyncCallback;

import mercurius.fitness.client.enumtypes.DietMeasurement;
import mercurius.fitness.client.enumtypes.Distance;
import mercurius.fitness.client.locale.Locale;
import mercurius.fitness.client.rb.diet.Diet;
import mercurius.fitness.client.rb.diet.DietRB;
import net.pleso.framework.client.bl.forms.IViewForm;
import net.pleso.framework.client.bl.forms.items.IFormItem;
import net.pleso.framework.client.bl.forms.items.IFormItemsGroup;
import net.pleso.framework.client.bl.forms.items.impl.FormItemsGroup;
import net.pleso.framework.client.bl.forms.items.impl.InfoEnumFormItem;
import net.pleso.framework.client.bl.forms.items.impl.InfoFormItem;

public class ViewDietForm extends DietFormReadOnly implements IViewForm {

	private Integer id = null;
	private String type = "";
	
	public ViewDietForm(Integer id, String type) {
			this.id = id;
			this.type = type;
	}

	public void GetData(AsyncCallback callback) {
		DietRB.getDataSet().get(this.id, callback,type);
	}

	public String getCaption() {
		return Locale.constants().view_exercise_caption();
	}

	public IFormItemsGroup[] getGroups() {
		if(type.equals(Diet.TYPE_LOG)) {
			IFormItem[] items = {
				
//				new InfoFormItem(Diet.Columns.heightunit, Height.getEnum()),
				new InfoFormItem(Diet.Columns.date),
				new InfoFormItem(Diet.Columns.time),
				new InfoFormItem(Diet.Columns.servings),
				new InfoFormItem(Diet.Columns.log_notes)
				
				};
			
			groups = new IFormItemsGroup[] { 
					new FormItemsGroup(null, items)
				};	
		} else if(type.equals(Diet.TYPE_MASTER_REPOSITORY) || type.equals(Diet.TYPE_PRIVATE_REPOSITORY)) {
			IFormItem[] items1 = {
					new InfoFormItem(Diet.Columns.name),
					new InfoFormItem(Diet.Columns.serving_size),
					new InfoFormItem(Diet.Columns.pdv_kcalories),
					new InfoFormItem(Diet.Columns.amount),
					new InfoEnumFormItem(Diet.Columns.amount_measurement, DietMeasurement.getEnum()),
					new InfoFormItem(Diet.Columns.calories),
					new InfoFormItem(Diet.Columns.fat_total),
					new InfoFormItem(Diet.Columns.fat_saturated),
					new InfoFormItem(Diet.Columns.fat_monounsaturated),
					new InfoFormItem(Diet.Columns.fat_polyunsaturated),
					new InfoFormItem(Diet.Columns.fat_trans),
					new InfoFormItem(Diet.Columns.cholesterol),
					new InfoFormItem(Diet.Columns.sodium),
					new InfoFormItem(Diet.Columns.potassium),
					new InfoFormItem(Diet.Columns.carb_total),
					new InfoFormItem(Diet.Columns.carb_fiber_dietary),
					new InfoFormItem(Diet.Columns.carb_fiber_soluble),
					new InfoFormItem(Diet.Columns.carb_fiber_insoluble),
					new InfoFormItem(Diet.Columns.carb_sugar),
					new InfoFormItem(Diet.Columns.carb_other),
					new InfoFormItem(Diet.Columns.protein),
					new InfoFormItem(Diet.Columns.Vitamin_A_retinol),
					new InfoFormItem(Diet.Columns.Vitamin_C_scorbic),
					new InfoFormItem(Diet.Columns.Mineral_Ca_Calcium),
					new InfoFormItem(Diet.Columns.Mineral_Fe_Iron),
					new InfoFormItem(Diet.Columns.nutrition_notes),
					};
			
			IFormItem[] items2 = {
					
					new InfoFormItem(Diet.Columns.Vitamin_B12_cyanocobalamin),
					new InfoFormItem(Diet.Columns.Vitamin_B1_thiamine),
					new InfoFormItem(Diet.Columns.Vitamin_B2_riboflavin),
					new InfoFormItem(Diet.Columns.Vitamin_B3_niacin),
					new InfoFormItem(Diet.Columns.Vitamin_B5_pantothenic),
					new InfoFormItem(Diet.Columns.Vitamin_B6_pyridoxine),
					new InfoFormItem(Diet.Columns.Vitamin_B7_biotin),
					new InfoFormItem(Diet.Columns.Vitamin_B9_folic),
					new InfoFormItem(Diet.Columns.Vitamin_choline),
					new InfoFormItem(Diet.Columns.Vitamin_D_calciferol),
					new InfoFormItem(Diet.Columns.Vitamin_E_tocopherol),
					new InfoFormItem(Diet.Columns.Vitamin_K_naphthoquinone),
					new InfoFormItem(Diet.Columns.Mineral_Br_Bromine),
					new InfoFormItem(Diet.Columns.Mineral_Co_Cobalt),
					new InfoFormItem(Diet.Columns.Mineral_Cr_chromium),
					new InfoFormItem(Diet.Columns.Mineral_Cu_Copper),
					new InfoFormItem(Diet.Columns.Mineral_Ge_Germanium),
					new InfoFormItem(Diet.Columns.Mineral_I_Iodine),
					new InfoFormItem(Diet.Columns.Mineral_Mg_Magnesium),
					new InfoFormItem(Diet.Columns.Mineral_Mn_Manganese),
					new InfoFormItem(Diet.Columns.Mineral_Mo_Molybdenum),
					new InfoFormItem(Diet.Columns.Mineral_P_Phosphorus),
					new InfoFormItem(Diet.Columns.Mineral_S_Sulfur),
					new InfoFormItem(Diet.Columns.Mineral_Se_Selenium),
					new InfoFormItem(Diet.Columns.Mineral_V_Vanadium),
					new InfoFormItem(Diet.Columns.Mineral_Zn_Zinc)
					};

				
				groups = new IFormItemsGroup[] { 
						new FormItemsGroup("General Nutrients", items1),
						new FormItemsGroup("Other Micro-Nutrients", items2),
					};
		}
		
		return groups;
	}
}
